package com.zggk.lzz.xcjl;

import android.app.Activity;

import com.alibaba.fastjson.JSON;
import com.zggk.lzz.api.MyApplication;
import com.zggk.lzz.api.Urls;
import com.zggk.lzz.callback.StringDialogCallback;
import com.zggk.lzz.mvp.BasePresenterImpl;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class XcjlPresenter extends BasePresenterImpl<XcjlContract.View> implements XcjlContract.Presenter{
    @Override
    public void getData(String orgName, String userName, String startDate, String endDate, Activity activity) {
        OkGo.<String>post(Urls.JAVASERVER+"pms/rhms/lzzapp/getPatrolInfoByScreen")
                .params("token", "Bearer$" + MyApplication.spUtils.getString("Token",""))
                .params("orgName", orgName)
                .params("userName", userName)
                .params("startDate", startDate)
                .params("endDate", endDate)
                .execute(new StringDialogCallback(activity) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        XcjlBean xcjlBean = JSON.parseObject(response.body(),XcjlBean.class);
                        if (mView == null)
                            return;
                        if (xcjlBean.getCode().equals("200")){
                            mView.getDatas(xcjlBean.getData());
                        }else {
                            mView.onRequestError(xcjlBean.getMessage());
                        }
                    }
                });
    }
}
